<template>
  <el-row class="utlis">
    <div class="selectDate">
      <span
        v-for="item in dateBtn"
        :class="{ active: item.isboolen }"
        @click="setMon(item)"
        >{{ item.poper }}</span
      >
    </div>
    <div class="right-cont">
      <el-cascader
        v-model="select"
        :options="options"
        class="thead-utils"
        clearable
        @change="changeVal"
        placeholder="请选择科室"
      />
      <el-input v-model="input" placeholder="请输入医生姓名" clearable />
      <el-button type="primary" @click="seachys">搜索</el-button>
      <el-button type="primary" @click="resetSH">重置</el-button>
    </div>
  </el-row>
</template>
<script>
import { ref, reactive, toRefs, computed, watch } from "vue";
import { useRouter } from "vue-router";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
export default {
  props: ["options"],
  setup(props, context) {
    const data = reactive({
      dateBtn: [
        { poper: "上一周", isboolen: false },
        { poper: "本周", isboolen: true },
        { poper: "下一周", isboolen: false },
      ],
      input: null,
      select: null,
    });
    const setMon = (val) => {
      context.emit("setMon", val.poper);
      data.dateBtn.forEach((item) => {
        if (item.poper == val.poper) {
          item.isboolen = ref(true);
        } else {
          item.isboolen = ref(false);
        }
      });
    };
    const changeVal = () => {
      if (data.select == null) {
        data.select = "";
      }
      context.emit("changeVal", data.select);
    };
    const seachys = () => {
      if (data.input == null) {
        data.input = "";
      }
      context.emit("seachys", data.input);
    };
    const resetSH = () => {
      data.input = null;
      data.select = null;
      context.emit("resetSH");
    };
    return { ...toRefs(data), setMon, changeVal, seachys, resetSH };
  },
};
</script>
<style lang="scss" scoped>
.flex {
  display: flex;
  align-items: center;
}
.utlis {
  @extend .flex;
  width: 100%;
  justify-content: space-between;
  height: 60px;
  .selectDate {
    @extend .flex;

    span {
      padding: 8px 36px;
      border: 1px solid #0066ff;
      color: #0066ff;
      cursor: pointer;
      &:nth-child(2) {
        border-right: none;
        border-left: none;
      }
      &:nth-child(1) {
        border-radius: 6px 0 0 6px;
      }
      &:nth-child(3) {
        border-radius: 0px 6px 6px 0px;
      }
    }
    .active {
      background-color: #0066ff;
      color: #fff;
    }
  }

  .el-input {
    height: 42px;
    width: 320px;
    margin-right: 20px;
  }
  .el-button {
    height: 42px;
    padding: 0 20px;
    background-color: #0066ff;
  }
}
</style>
<style>
.thead-utils {
  margin-right: 20px;
}
.thead-utils .el-input {
  height: 42px;
}
</style>
